<?php
require_once "./Mobile-Detect/Mobile_Detect.php";
$detect        = new Mobile_Detect;
$deviceType    = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');
$scriptVersion = $detect->getScriptVersion();

$d = strtotime("tomorrow");
$d = '2019-08-05 11:23:32';

echo date("Y-m-d h:i:sa", strtotime($d)) . "<br>";

$d = strtotime("next Saturday");
echo date("Y-m-d h:i:sa", $d) . "<br>";

$d = strtotime("+3 Months");
echo date("Y-m-d h:i:sa", $d) . "<br>";

$time = strtotime(date("2019-08-05 11:23:32"));
echo "time=" . $time;

echo "<br>字串=" . md5(uniqid(md5(microtime(true)), true));
$a = 5;
if (strstr('1,5', $a)) {
    echo "<br>5包含于字串";

}
echo "<br>abcd*********<br>";
echo "time=" . strtotime("2109-10-21 16:00:10");

echo "time2=" . strtotime('2038-03-24 08:15:42');

$obj = new DateTime("2050-12-31 23:59:59");
echo 'time3=' . $obj->format("U");
$str = 'ABC874';
echo "<br>str=" . substr($str, 1);

$arr = array(0 => '', 1 => '');
var_dump($arr);

if (!empty($arr)) {
    echo "有值";
}

echo "moon=" . date('n');

$list = [
    0 => [
        'id'   => 1001,
        'name' => '张三',
        'sex'  => '男',
    ],
    1 => [
        'id'   => 2091,
        'name' => '李四',
        'sex'  => '女',
    ],
];

$arr2 = array_map('array_shift', $list);
$arr3 = array_remove_key($list, array('id', 'sex'));

echo "日=" . date('d', strtotime("-15 day"));
var_dump($arr2);
var_dump($arr3);
function array_remove_key($array, $keys)
{
    if (!is_array($array) || !is_array($keys)) {
        return false;
    }
    foreach ($array as $t) {
        foreach ($keys as $k) {
            unset($t[$k]);
        }
        $doc[] = $t;
    }
    return $doc;
}

echo strtotime(date('Y-m-d', strtotime("+365 day")) . ' 23:59:59');

$firstday = date("Y-m-01", strtotime('2019-09-16'));
$lastday  = date("Y-m-d", strtotime("$firstday +1 month -1 day"));

echo "firstday=" . strtotime($firstday);

$array = array('协议管理' => 'admin/showfile',
    0                     => 'test/test2',
    1                     => 'test/test3',
    '用户量体管理'              => 'user/tempera',
    '商品展示分类'              => 'goodstype/list',
    '商品自定义模版'             => 'customtemplate/list',
    '型男穿搭'                => 'typeman/list',
    '积分规则'                => 'integral/list',
    '会员卡列表'               => 'memcard/list',
    '会员权益'                => 'mempower/list',
    '会员列表'                => 'user/card',
    '会员积分明细'              => 'user/integral',
    '会员储值明细'              => 'user/stored',
    2                     => 'goodscategory/list',
    3                     => 'goods/list',
    4                     => 'order/list',
    5                     => 'banner/list',
    6                     => 'shop/shipfee',
    7                     => 'payflow/list',
    8                     => 'payflow/summary',
    9                     => 'productattroption/list',
    10                    => 'card/list',
    11                    => 'factory/list',
    12                    => 'template/list',
    13                    => 'user/address',
    14                    => 'user/appraise',
    15                    => 'user/collect',
    16                    => 'user/cart',
    17                    => 'test/test');
$val = 'test/test';
echo "abcd=" . implode(",", $array);

if (!in_array($val, $array)) {
    echo "$val" . "不在数组中";
}

if (!strstr(implode(",", $array), $val)) {
    echo "<br>$val不包含于字串";

}

$a = 'ａｂｃ１２ ３４ ５ ';

$dbc = make_semiangle(preg_replace('# #', '', $a));
var_dump($dbc);

/**
 *  将一个字串中含有全角的数字字符、字母、空格或'%+-()'字符转换为相应半角字符
 *
 * @access  public
 * @param   string       $str         待转换字串
 *
 * @return  string       $str         处理后字串
 */
function make_semiangle($str)
{
    $arr = array('０' => '0', '１' => '1', '２' => '2', '３' => '3', '４' => '4',
        '５'              => '5', '６' => '6', '７' => '7', '８' => '8', '９' => '9',
        'Ａ'              => 'A', 'Ｂ' => 'B', 'Ｃ' => 'C', 'Ｄ' => 'D', 'Ｅ' => 'E',
        'Ｆ'              => 'F', 'Ｇ' => 'G', 'Ｈ' => 'H', 'Ｉ' => 'I', 'Ｊ' => 'J',
        'Ｋ'              => 'K', 'Ｌ' => 'L', 'Ｍ' => 'M', 'Ｎ' => 'N', 'Ｏ' => 'O',
        'Ｐ'              => 'P', 'Ｑ' => 'Q', 'Ｒ' => 'R', 'Ｓ' => 'S', 'Ｔ' => 'T',
        'Ｕ'              => 'U', 'Ｖ' => 'V', 'Ｗ' => 'W', 'Ｘ' => 'X', 'Ｙ' => 'Y',
        'Ｚ'              => 'Z', 'ａ' => 'a', 'ｂ' => 'b', 'ｃ' => 'c', 'ｄ' => 'd',
        'ｅ'              => 'e', 'ｆ' => 'f', 'ｇ' => 'g', 'ｈ' => 'h', 'ｉ' => 'i',
        'ｊ'              => 'j', 'ｋ' => 'k', 'ｌ' => 'l', 'ｍ' => 'm', 'ｎ' => 'n',
        'ｏ'              => 'o', 'ｐ' => 'p', 'ｑ' => 'q', 'ｒ' => 'r', 'ｓ' => 's',
        'ｔ'              => 't', 'ｕ' => 'u', 'ｖ' => 'v', 'ｗ' => 'w', 'ｘ' => 'x',
        'ｙ'              => 'y', 'ｚ' => 'z',
        '（'              => '(', '）' => ')', '〔' => '[', '〕' => ']', '【' => '[',
        '】'              => ']', '〖' => '[', '〗' => ']', '“' => '[', '”' => ']',
        '‘'              => '[', '’' => ']', '｛' => '{', '｝' => '}', '《' => '<',
        '》'              => '>',
        '％'              => '%', '＋' => '+', '—' => '-', '－' => '-', '～' => '-',
        '：'              => ':', '。' => '.', '、' => ',', '，' => '.', '、' => '.',
        '；'              => ',', '？' => '?', '！' => '!', '…' => '-', '‖' => '|',
        '”'              => '"', '’' => '`', '‘' => '`', '｜' => '|', '〃' => '"',
        '　'              => ' ');

    return strtr($str, $arr);
}

$a1 = array("a", "b", '', 2, 3, 4, '');
print_r($a1);
print_r(array_filter($a1, "strlen"));
$a1 = array('phone' => '18916211263');
print_r(json_encode($a1));

$str = '领型';
if (preg_match("/[\x7f-\xff]/", $str)) {
    echo "$str" . "是中文";
} else {
    echo "$str" . "不是中文";
}

$a = array('abc' => "red", 'abc2' => "green");
$b = array('abc3' => 'blue');
$c = array_merge($a, $b);
print_r($c);

$str = hash_hmac('sha256', '123456', '%@#$!^*&');

echo "<br>" . $str;
$int = '';
$abc = (int) $int;
echo "abc=" . $abc;

$result     = "test";
$field_name = 'lywf_factory' . date('Ym') . ".log";
error_log(date('Y-m-d H:i:s') . "\t推送订单到工厂返回结果\n" . $result . "\n", 3, '/tmp/' . $field_name);

$str = str_pad(1, 8, '#', STR_PAD_BOTH);
echo "<br>" . $str;
$str = print_str($str);
echo "<br>strlen".strlen($str) . $str;

function print_str($strs)
{
    $array = explode('#', $strs);
    $result = '';    
    foreach ($array as $key => $value) {
        if ($value == "") {
            $result .= ' ';
        } else {
            $result .= $value;
        }
    }
    return $result; 
}

//右截取

$abc="wx4cc6ee8b7ea8ecef_odyL_4zTvhMbTt7gZaG5CK2IFUuc";

$result = substr ($abc, -28);
echo "<br>";
echo($result);

 $data = array();
        $data['reason_txt'] = '1';
        $data['order_id'] =2;
        $data['order_detail_id'] = 3;
        $data['shop_id'] = 4;
var_dump($data);
 $data = array(
                    'touser' =>  'openid' ,
                    'template_id' => '4wtjNWewNgTNCdvbcp_pgkeEr2ODh6eJl0KQkhgCJYw',
                    //'url' => 'http://biz.redcells.cc/peisong/order?id=',
                    /*原因：缺料
                    模型：小兔子
                    地址：瑞安市 安阳新区 瑞光大道28号
                    名称：电影院二号 【DYL0239409238409
                    时间：2017.10.14 15:54
                    感谢你的使用。*/
                    'data' => array(
                        'first' => '报告主人，有人申请退款：5元！',
                        'keyword1' =>  '1' ,
                        'keyword2' => '/',
                        'keyword3' =>  2,
                        'keyword4' => 3,
                        'keyword5' => date('Y-m-d H:i:s'),
                        'remark' => '感谢你的使用。',
                    ),
                );

var_dump($data);